#include <iostream>
#include <string> 
using namespace std;

string s,s1;

int main(){
	cin >> s;
	for(int i = s.size() - 1;i >= 0;i--){
		s1[s.size() - i - 1] = s[i];
	}
	int ret = stoi(s1,NULL,2);
	cout << ret << endl;
	return 0;
}
